<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>12-嵌套命名视图</title>
</head>
<body>
  <div id="app">
    <h1>Hello VueRouter</h1>
    <router-link to='/home'>home</router-link>
    <router-link to='/user/a'>user/a</router-link>
    <router-link to='/user/b'>user/b</router-link>
    <router-view></router-view>
  </div>
</body>
<!-- 引入Vue -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- 引入VueRouter -->
<script src="https://unpkg.com/vue-router@3.5.1/dist/vue-router.js"></script>
<script>
  const UserA = {
    template:`<div>
       <h1>这里是UserA组件</h1>
      </div>`,
    }
  const UserB = {
    template:`<div>
       <h1>这里是UserB组件</h1>
      </div>`,
    }
  const UserC = {
    template:`<div>
       <h1>这里是UserC组件</h1>
      </div>`,
    }

  const User = {template:`
    <div>
      <h1>这里是User组件</h1>
      <router-view></router-view>
      <router-view name='userRWB'></router-view>  
    </div>`,
  }
  
  const Home = {
    tempalte:`<div>
        <h1 style='background:pink;'>这里是Home组件</h1>  
      </div>`,
  }

  var routes = [
    // {path:'',component: Home},
    {path:'/home',component: Home},
    {path:'/user',component: User,children:[
      {path:'',component: UserA},
      {path:'a',component: UserA},
      {path:'b',components: {
        default: UserB,
        userRWB: UserC,
      }}
    ]}
  ]
  
  var router = new VueRouter({
    routes
  });

  var app = new Vue({
    el:'#app',
    router
  })
</script>
</html>